package main

import "fmt"

/**
全局变量
*/
var a int = 10
var b int // 将被赋予零值
var c = 20

/**
expected type, found newlinesyntax
var d
*/

/**
expected declaration, found esyntax
此种定义方式仅在函数体内有效
e := 30
*/

var (
	v1 int = 100
	v2 bool = true
)

var (
	v3 = 200
	v4 = false
)

var (
	v5 int
	v6 bool
)

var global_int int

/**
这里赋值会报错，这种方式定义只能在函数体内进行赋值
global_int = 10
*/

func main() {
	global_int = 300
	fmt.Println(a, b, c, v1, v2, v3, v4, v5, v6, global_int)

	var local_a int = 111
	var local_b int
	local_b = 222
	var local_c = 333
	local_d := 444
	fmt.Println(local_a, local_b, local_c, local_d)

	var (
		local_v1 int = 555
		local_v2 bool = true
	)

	var (
		local_v3 = 666
		local_v4 = false
	)

	var (
		local_v5 int
		local_v6 bool
	)

	local_v5 = 777
	local_v6 = true

	fmt.Println(local_v1, local_v2, local_v3, local_v4, local_v5, local_v6)

	/**
	一次定义多个变量
	*/
	var x, y, z = 1, "string", false
	fmt.Println(x, y, z)
}